#pragma once
//////////////////////////////////////////////////////////////////////////
using namespace System::Drawing;
using namespace System::Drawing::Imaging;
using namespace System::Globalization;
//////////////////////////////////////////////////////////////////////////
NAMESPACE_BEGIN_UI
//////////////////////////////////////////////////////////////////////////
public ref class ManagedImageConverter
{
public:
	static array<Color>^ CreateGray8DepthPalette();
	static array<Color>^ CreateGray16DepthPalette();

private:
	static void FillBitmapData8U1C(BitmapData^ data, void* pLine0, int stride, Color* palette);
	static void FillBitmapData16U1C(BitmapData^ data, void* pLine0, int stride, Color* palette);
	static void FillBitmapData8U3C(BitmapData^ data, void* pLine0, int stride);
	static void FillBitmapData8U4C(BitmapData^ data, void* pLine0, int stride);
	static Bitmap^ BuildBitmapFromCache(ManagedImage^ img, Bitmap^ cache);
	static Bitmap^ BuildBitmapFromCache(ManagedMat^ img, Bitmap^ cache);
	static bool CheckPixelFormatIsSupport(ManagedImage^ img);
	static bool CheckPixelFormatIsSupport(ManagedMat^ img);

public:
	static Bitmap^ Convert(ManagedArr^ img, Bitmap^ cache, array<Color>^ palette);
	static ManagedImage^ Convert(Bitmap^ bitmap, ManagedImage^ cache);

public:
	System::Object^ Convert(System::Object^ value, System::Type^ targetType, System::Object^ parameter, CultureInfo^ culture);
    System::Object^ ConvertBack(System::Object^ value, System::Type^ targetType, System::Object^ parameter, CultureInfo^ culture);
};
//////////////////////////////////////////////////////////////////////////
NAMESPACE_END_UI
//////////////////////////////////////////////////////////////////////////